package com.matrix.java.chap_07;

import java.util.Arrays;

/*
    倒置数组
 */
public class Ex7_12 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        reverse(arr);
    }

    public static void reverse(int[] list) {
        int[] result = new int[list.length];
        for (int i = 0, j = result.length - 1; i < list.length; i++, j--) {
            result[j] = list[i];
        }
        System.arraycopy(result, 0, list, 0, result.length);
        System.out.println(Arrays.toString(list));
    }
}
